﻿using System;
using EzDesk.Core.Model;
using EzDesk.EzAppApi.Utility;
using EzDesk.Utility.Extensions;
using EzDesk.Utility.Web.Extensions;
using EzDesk.Utility;
using EzDesk.Utility.Web.ViewModels;
using EzDesk.Apps.Model.Attendance;

namespace EzDesk.Clients.DesktopWeb.Attendance.ViewModel
{
    public class AttendanceInfoModel : ViewModelBase
    {
        public Guid Id { get; set; }
        public SimpleUser User { get; set; }
        public int Date { get; set; }
        public string AttendanceType { get; set; }
        public int ActionTime { get; set; }
        public string Explanation { get; set; }
        public bool IsAbnormalAttendance { get; set; }

        public AttendanceInfoModel(AttendanceInfo info)
        {
            this.Id = info.Id;
            this.User = this.GetEzApiClient().GetSimpleUserById(info.UserId);
            this.Date = info.Date.ToEpoch(); ;
            this.AttendanceType = info.AttendanceType.GetEnumName();
            this.ActionTime = info.ActionTime.ToEpoch();
            this.Explanation = info.Explanation;
            this.IsAbnormalAttendance = info.IsAbnormalAttendance;
        }
    }
}